package com.iss.okair.db.mapper.sql;

import com.iss.common.StringTools;
import com.iss.okair.db.entity.AssetsFinance;
import com.iss.okair.db.entity.Category;
import org.apache.ibatis.jdbc.SQL;
public class CategorySQL {

    //动态生成查询语句
    public String findgory(Category example){

        return new SQL(){
            {
               SELECT("xj.*,CONCAT(sj.code,'',sj.namecn) as parentname");
               FROM("category xj LEFT JOIN category sj ON(xj.parentId = sj.id)");
               if(example.getNamecn()!=null){
                   WHERE("xj.namecn like '%"+example.getNamecn()+"%'");
               }
                if(example.getParentid()!=-1){
                    WHERE("xj.parentid=#{parentid}");
                }
            }

        }.toString();
    }
}
